package com.gao.gLotusMusic.controller;

import com.gao.gLotusMusic.task.Task;
import com.gao.gLotusMusic.view.TopUi;
import com.gao.musicApi.model.SearchModel;
import com.gao.musicApi.model.Song;
import com.gao.musicApi.service.MusicApi;
import com.gao.musicApi.service.impl.MiguApi;

import java.util.List;

public class TopController {
    private MusicApi api = new MiguApi();

    private static class instance {
        private static TopController instance = new TopController();
    }

    public static TopController getInstance() {
        return instance.instance;
    }

    private TopController() {
    }

    public void search(String kw) {
        SearchModel model = new SearchModel();
        model.setKw(kw);
        model.setPage(1);
        Task.async(() -> {
            List<Song> r = api.search(model);
            TopUi.instance.searchHandle(r);
        });

    }
}
